/**
 * Copyright 2021 Inc.
 **/
package com.myz.rabbitmq.common.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 发布订阅模型
 *
 * @author maoyz0621 on 2021/6/7
 * @version v1.0
 */
@Configuration
public class FanoutExchangeConfig {

    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange(RabbitMqConstant.ExchangeEnum.CONTRACT_FANOUT.getCode(), true, false);
    }

    @Bean
    public Binding bindingFanout(Queue firstQueue) {
        return BindingBuilder.bind(firstQueue).to(fanoutExchange());
    }
}